<include target="header.html" />
<!--TODO-->
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == ''" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
	<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>

<table id="boardList" class="x_table x_table-striped x_table-hover">
	<caption>
		<strong>Total: {number_format($total_count)}, Page: {number_format($page)}/{number_format($total_page)}</strong>
	</caption>
	<thead>
		<tr>
			<th scope="col">{$lang->no}</th>
			<th scope="col">{$lang->module_category}</th>
			<th scope="col">{$lang->mid}</th>
			<th scope="col">{$lang->browser_title}</th>
			<th scope="col">{$lang->regdate}</th>
			<th scope="col">{$lang->cmd_edit}</th>
			<th scope="col"><input type="checkbox" data-name="cart" title="Check All" /></th>
		</tr>
	</thead>
	<tbody>
		<tr loop="$board_list => $no,$val">
			<td>{$no}</td>
			<td>
				<block cond="!$val->module_category_srl">
					<block cond="$val->site_srl">{$lang->virtual_site}</block>
					<block cond="!$val->site_srl">{$lang->not_exists}</block>
				</block>
				<block cond="$val->module_category_srl">{$module_category[$val->module_category_srl]->title}</block>
			</td>
			<td>{$val->mid}</td>
			<td><a href="{getSiteUrl($val->domain,'','mid',$val->mid)}">{$val->browser_title}</a></td>
			<td>{zdate($val->regdate,"Y-m-d")}</td>
			<td>
				<a href="{getUrl('act','dispBoardAdminBoardInfo','module_srl',$val->module_srl)}" class="x_icon-cog" title="{$lang->cmd_setup}">{$lang->cmd_setup}</a>
				<a href="{getUrl('','module','module','act','dispModuleAdminCopyModule','module_srl',$val->module_srl)}" class="x_icon-plus" onclick="popopen(this.href);return false;" title="{$lang->cmd_copy}">{$lang->cmd_copy}</a>
				<a href="{getUrl('act','dispBoardAdminDeleteBoard','module_srl', $val->module_srl)}" class="x_icon-remove" title="{$lang->cmd_delete}">{$lang->cmd_delete}</a>
			</td>
			<td><input type="checkbox" name="cart" value="{$val->module_srl}" class="selectedModule" data-mid="{$val->mid}" data-browser_title="{$val->browser_title}" /></td>
		</tr>
		<tr cond="!$board_list">
			<td>{$lang->no_board_instance}</td>
		</tr>
	</tbody>
</table>

<div class="x_clearfix">
	<form cond="$page_navigation" action="./" class="x_pagination x_pull-left" no-error-return-url="true" style="margin-top:0">
		{@
			$urlInfo = parse_url(getRequestUriByServerEnviroment());
			parse_str($urlInfo['query'], $param);
		}
		<input loop="$param => $key, $val" cond="!in_array($key, array('mid', 'vid', 'act'))" type="hidden" name="{$key}" value="{$val}" />
		<ul>
			<li class="x_disabled"|cond="!$page || $page == 1"><a href="{getUrl('page', '')}">&laquo; {$lang->first_page}</a></li>
			<block cond="$page_navigation->first_page != 1 && $page_navigation->first_page + $page_navigation->page_count > $page_navigation->last_page - 1 && $page_navigation->page_count != $page_navigation->total_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
			</block>
			<!--@while($page_no = $page_navigation->getNextPage())-->
			{@$last_page = $page_no}
			<li class="x_active"|cond="$page_no == $page"><a  href="{getUrl('page', $page_no)}">{$page_no}</a></li>
			<!--@end-->
			<block cond="$last_page != $page_navigation->last_page && $last_page + 1 != $page_navigation->last_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
			</block>
			<li class="x_disabled"|cond="$page == $page_navigation->last_page"><a href="{getUrl('page', $page_navigation->last_page)}" title="{$page_navigation->last_page}">{$lang->last_page} &raquo;</a></li>
		</ul>
	</form>
	<span class="x_pull-right x_btn-group">
		<!--<a class="x_btn x_btn-inverse" href="{getUrl('act','dispBoardAdminInsertBoard','module_srl','')}">{$lang->cmd_create_board}</a>-->
		<a class="x_btn modalAnchor _manage_selected" href="#manageSelectedModule">{$lang->cmd_manage_selected_board}</a>
	</span>
</div>
<form action="" class="search x_input-append center" no-error-return-url="true">
	<input loop="$param => $key, $val" cond="!in_array($key, array('mid', 'vid', 'act', 'page', 'search_target', 'search_keyword'))" type="hidden" name="{$key}" value="{$val}" />
	<select cond="count($module_category)" name="module_category_srl" title="{$lang->module_category}" style="margin-right:4px">
		<option value="" selected="selected"|cond="!$module_category_srl">{$lang->all}</option>
		<option value="0" selected="selected"|cond="$module_category_srl==='0'">{$lang->not_exists}</option>
		<option value="{$key}" loop="$module_category => $key,$val"  selected="selected"|cond="$module_category_srl==$key">{$val->title}</option>
	</select>
	<select name="search_target" title="{$lang->search_target}" style="margin-right:4px">
		<option value="mid" selected="selected"|cond="$search_target=='mid'">{$lang->mid}</option>
		<option value="browser_title" selected="selected"|cond="$search_target=='browser_title'">{$lang->browser_title}</option>
	</select>
	<input type="search" required name="search_keyword" value="{htmlspecialchars($search_keyword)}" />
	<button class="x_btn x_btn-inverse" type="submit">{$lang->cmd_search}</button>
	<a class="x_btn" href="{getUrl('', 'module', $module, 'act', $act)}">{$lang->cmd_cancel}</a>
</form>

{$selected_manage_content}

<script>
jQuery(function($){
	// Modal anchor activation
	var $docTable = $('#boardList');
	$docTable.find(':checkbox').change(function(){
		var $modalAnchor = $('a.modalAnchor._manage_selected');
		if($docTable.find('tbody :checked').length == 0){
			$modalAnchor.removeAttr('href').addClass('x_disabled');
		} else {
			$modalAnchor.attr('href','#manageSelectedModule').removeClass('x_disabled');
		}
	}).change();
	// Button action
	$('a.modalAnchor._manage_selected').click(function(){
		if($docTable.find('tbody :checked').length == 0){
			$('body').css('overflow','auto');
			alert('{$lang->choose_board_instance}');
			return false;
		}
	});
});
</script>
